package com.jinmdz.fmis.dao.admin.dao;

import com.jinmdz.fmis.dao.admin.model.loungehome.LoungeHomeEditItem;
import com.jinmdz.fmis.dao.admin.model.loungehome.LoungeHomeListItem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;

/**
 * 休息室房间表Dao
 * 
 * @author SunZhaoQi
 * @date 2020-08-23 18:11
 */
public interface LoungeHomeDao {



    /**
     * 查询LoungeHome列表
     *
     * @return LoungeHomeItem
     * @author SunZhaoQi
     * @date 2020-08-23 18:11
     */
    @Select(" select id,home_type_code,home_code,home_name,disable_state,sort,remark,version " +
            "  from lounge_home where deleted = 0 order by sort")
    ArrayList<LoungeHomeListItem> listLoungeHomeList();

    /**
     * 按照主键获取休息表信息
     *
     * @param id 主键
     * @return
     * @author SunZhaoQi
     * @date 2020-08-23 13:45
     */
    @Select(" select id,home_type_code,home_code,home_name,disable_state,sort,remark,version" +
            "  from lounge_home where id = #{id} and deleted = 0 limit 1")
    LoungeHomeEditItem getLoungeHomeEditById(@Param("id") Integer id);


    /**
     * 按照礼厅编码查询非当前休息室信息主键
     *
     * @param loungeHomeId   当前休息室主键
     * @param homeCode 礼厅编码
     * @return
     * @author SunZhaoQi
     * @date 2020-08-23 15:10
     */
    @Select(" select id from lounge_home where id != IFNULL(#{loungeHomeId},0) and home_code = #{homeCode} and deleted = 0 limit 1 ")
    @ResultType(Integer.class)
    Integer getLoungeHomeIdByHomeCode(@Param("loungeHomeId") Integer loungeHomeId, @Param("homeCode") String homeCode);


    /**
     * 按照礼厅编码查询休息室信息主键
     *
     * @param homeId   礼厅主键
     * @param homeName 礼厅名称
     * @return
     * @author SunZhaoQi
     * @date 2020-08-23 15:27
     */
    @Select(" select id from lounge_home where id != IFNULL(#{homeId},0) and home_name = #{homeName} and deleted = 0 limit 1 ")
    @ResultType(Integer.class)
    Integer getLoungeHomeIdByHomeName(@Param("homeId") Integer homeId, @Param("homeName") String homeName);
}

